import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gameplay_flutter/lib_runtime/extension/string_extension/string_text.dart';
import 'package:gameplay_flutter/m_room/constants/room_assets.dart';

class RoomPrivacy extends StatefulWidget {
  const RoomPrivacy({Key? key}) : super(key: key);

  @override
  _RoomPrivacyState createState() => _RoomPrivacyState();
}

class _RoomPrivacyState extends State<RoomPrivacy> {
  @override
  Widget build(BuildContext context) {
    return IntrinsicHeight(
      child: SafeArea(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(
              height: 12.h,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Padding(
                  padding: EdgeInsetsDirectional.only(start: 19.w,top: 3.h,bottom: 3.h),
                  child: "Cancel".text(
                    fontSize: 16.sp,
                    color: const Color(0xFFC1C1C1),
                    weight: TextFontWeight.regular,
                  ),
                ),
                "Privacy".text(
                  fontSize: 22.sp,
                  color: Colors.white,
                  weight: TextFontWeight.medium,
                ),
                Padding(
                  padding: EdgeInsetsDirectional.only(end: 19.w,top: 3.h,bottom: 3.h),
                  child: "Cancel".text(
                    fontSize: 16.sp,
                    color: Colors.transparent,
                    weight: TextFontWeight.regular,
                  ),
                ),
              ],
            ),
            SizedBox(
              height: 19.h,
            ),
            _buildPrivacyItem("Open Room", "Visible To All..."),
            SizedBox(
              height: 20.h,
            ),
            _buildPrivacyItem("Open Room", "By Invitation..."),
            SizedBox(
              height: 34.h,
            ),
            Container(
              height: 44.h,
              width: 240.w,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(24.r),
                gradient: const LinearGradient(
                  colors: [
                    Color(0xFF8A72FE),
                    Color(0xFF6549EC),
                  ],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                ),
              ),
              child: "Save".text(
                fontSize: 20.sp,
                color: Colors.white,
                weight: TextFontWeight.medium,
              ),
            ),
            SizedBox(
              height: 27.h,
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildPrivacyItem(String title, String subTitle) {
    return Container(
      height: 62.h,
      margin: EdgeInsetsDirectional.symmetric(horizontal: 15.w),
      padding: EdgeInsetsDirectional.only(start: 11.w, end: 10.w),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(4.r),
        border: Border.all(
          color: const Color(0xFF8A72FE),
          width: 1.w,
        ),
      ),
      child: Row(
        children: [
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              title.text(
                fontSize: 14.sp,
                color: Colors.white,
                weight: TextFontWeight.regular,
              ),
              SizedBox(
                height: 6.h,
              ),
              subTitle.text(
                fontSize: 14.sp,
                color:const Color(0xFF755793),
              )
            ]
          ),
          Spacer(),
          Image.asset(
            RoomAssets.roomItemSelect,
            width: 24.w,
            height: 24.h,
          )
        ]
      )
    );
  }
}
